﻿@{ ViewBag.Title = "Index";
    Layout = "~/Areas/Shared/_LayuiList.cshtml"; }

<blockquote class="layui-elem-quote">
    基础信息表和自由流程不能设置流程步骤；如需删除流程进入录入表管理页面，删除录入表便可删除对应流程
</blockquote>

<!--数据表格-->
<table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
<script>
    layui.use(["table", "form", "exLayer", "exUtils", "miniPage"], function () {
        let table = layui.table;
        let form = layui.form;
        let exLayer = layui.exLayer;
        let exUtils = layui.exUtils;
        let miniPage = layui.miniPage;

        let $ = layui.$;
        var openWH = miniPage.getOpenWidthHeight();

        let ThisTable = table.render({
            elem: "#tableId",
            url: "/SysFlow/Flow/GetList",
            limit: 100,
            page: true,

            cols: [[
                { field: "FlowId", title: "编码", sort: true },
                { field: "FlowName", title: "名称", sort: true },
                { field: "FlowType", title: "类型", sort: true, width: 100, templet: "#FlowType" },
                { title: "操作", width: 200, align: "center", fixed: "right", templet: "#operationTpl" }
            ]],
            done: function (res, curr, count) {
                console.log(res, curr, count);
            }
        });

        table.on("toolbar(tableFilter)", function (obj) {
            switch (obj.event) {
                case "add":
                    add();
                    break;
                case "refresh":
                    refresh();
                    break;
            }
        });

        table.on("tool(tableFilter)", function (obj) {
            let data = obj.data;
            switch (obj.event) {
                case "edit":
                    edit(data.FlowId, data.FlowName);
                    break;
                case "flowprcs":
                    flowPrcs(data.FlowId, data.FlowName, data.TbId, data.FlowType);
                    break;
            }
        });

        function refresh() {
            ThisTable.reload({
            });
        }

        function edit(id, name) {
            exLayer.open(name + "-编辑", "/SysFlow/Flow/Edit?id=" + id, '100%', '100%', '0px', '0px', null, null);
        }

        function flowPrcs(id, name, tbid, type) {
            if (type == "0") {
                exLayer.yellowSighMsg("基础信息录入表不能设置流程步骤");
                return false;
            }
            if (type == "2") {
                exLayer.yellowSighMsg("自由流程无需设置流程步骤");
                return false;
            }
            exLayer.open(name + "-流程步骤", "/SysFlow/FlowPrcs/List?id=" + id + "&tbid=" + tbid, '100%', '100%', '0px', '0px', null, null);
        }
    });
</script>
<script type='text/html' id='FlowType'>
    {{#  if(d.FlowType == 1){ }}
    固定流程
    {{#  } }}
    {{#  if(d.FlowType == 2){ }}
    自由流程
    {{#  } }}
    {{#  if(d.FlowType == 0){ }}
    无流程
    {{#  } }}
</script>
<!-- 行工具栏模板 -->
<script type="text/html" id="operationTpl">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit" id="edit">基本属性</a>

    {{#  if(d.FlowType == '1'){ }}
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="flowprcs" id="flowprcs">流程步骤</a>
    {{#  }else{ }}
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="flowprcs" id="flowprcs">流程步骤</a>
    {{#  } }}
</script>